package com.sen.gateway.config;

import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.sen.gateway.route.NacosRouteDefinitionRepository;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 动态路由配置
 * @author esjiang
 */
@Configuration
public class DynamicRouteConfig {
    @Resource
    private ApplicationEventPublisher publisher;

    @Resource
    private NacosConfigProperties nacosConfigProperties;

    @Bean
    public NacosRouteDefinitionRepository nacosRouteDefinitionRepository() {
        return new NacosRouteDefinitionRepository(publisher, nacosConfigProperties);
    }
}
